package com.midcent.networklib.interfac;

import java.io.FileInputStream;
import java.util.Properties;

/**
 * Created by kexiang on 16/3/22.
 */
public class ErrorCode {
    public String file = "ErrorCode.properties";


    public static void recieveError(int code){

    }

    public static int SERVER_ID = 1;
    public static int SERVER_PORT = 3999;

    private static Properties conf;

    public static void init(String file) {

        try {
            conf = new Properties();
            conf.load(new FileInputStream(file));
        } catch (Exception e) {

        }

    }

    public static int getIntValue(String key) {
        String valueStr = getValue(key);
        int value = 0;
        if (valueStr != null) {
            try {
                value = Integer.valueOf(valueStr);
            } catch (Exception e) {

            }
        }
        return value;
    }

    public static String getValue(String key) {
        if (conf == null) {
            return null;
        }
        return conf.getProperty(key);
    }
}
